<template>
  <el-card class="box-card">
		<div slot="header" class="clearfix">
			<span>报表导出</span>
			<!-- <el-button style="float: right; padding: 3px 0" type="text" @click="showGoodsCreateForm=true">新增商品</el-button> -->
		</div>
		<el-form ref="form" :model="temperatureParams" label-width="80px">
			<el-form-item label="体温">
				<el-input v-model="temperatureParams.temperature"></el-input>
			</el-form-item>
			<el-form-item label="日期">
				 <el-date-picker
					v-model="temperatureParams.time"
					type="date"
					placeholder="选择日期">
				</el-date-picker>
			</el-form-item>
			<el-button type="success" @click="getStatsTemperature">导出体温报表</el-button>
			<a :href="temperatureURL" v-if="temperatureURL">下载</a>
		</el-form>

		<el-form ref="form" :model="regionParams" label-width="80px">
			<el-form-item label="体温">
				<el-input v-model="regionParams.country"></el-input>
			</el-form-item>
			<el-form-item label="体温">
				<el-input v-model="regionParams.province"></el-input>
			</el-form-item>
			<el-form-item label="体温">
				<el-input v-model="regionParams.district"></el-input>
			</el-form-item>
			<el-button type="primary" @click="getStatsRegion">导出地区报表</el-button>
			<a :href="regionURL" v-if="regionURL">下载</a>
		</el-form>
		<el-row>
			
			
		</el-row>
	</el-card>
</template>

<script>
import { getStats,getStatsTemperature,getStatsRegion } from '@/api/common'
	export default {
		name: 'Goods',
		data() {
			return {
				// 获取体温报表参数
				temperatureParams: {
					temperature: 36,
					time: '2021-6-20'
				},
				temperatureURL: undefined,
				// 体温报表id
				temperatureId: '',
				// 获取地区报表参数
				regionParams: {
					country: '中国',
					province: '广东省',
					district: '东莞市'
				},
				// 地区报表id
				regionId: '',
				regionURL: undefined,
			}
		},
		props: {
			// 获取父组件参数
		},
		components: {
			// 包含组件
		},
		methods:{
			// 导出体温报表
			getStatsTemperature(){
				getStatsTemperature(this.temperatureParams).then(res => {
					getStats(res.msg).then(res => {
						this.temperatureURL = res.data
						console.log(this.temperatureURL);
					})
					 
				})
			},

			// 导出地区报表
			getStatsRegion(){
				getStatsRegion(this.regionParams).then(res => {
					getStats(res.msg).then(res => {
						this.regionURL = res.data
						console.log(this.regionURL);
					})
				})
			},

		},
		computed:{
				//计算属性
				
		},
		watch:{
				//监听属性
		},
		created() {
				//console.log('created函数......');
		}
	}
</script>

<style scoped>
	.box-card{
		width: 100%;
		height: 100%;
		overflow: auto;
	}
</style>